package lab02.test23;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Scanner;

public class  Test {
    public static void main(String[] args) throws ParseException {
        //23、 	编写Java应用程序，从命令行输入你的生日信息，
        // 然后计算你的生日还有多少天，你的生日是星期几。
        String birthday;
        Scanner scanner = new Scanner(System.in);
        System.out.println("Please your birthday:");
        birthday = scanner.nextLine();
        System.out.println(birthday);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Calendar time = Calendar.getInstance();
        time.setTime(sdf.parse(birthday));
        long time1 = time.getTimeInMillis();
        time.setTime(sdf.parse("2017-11-02"));
        long time2 = time.getTimeInMillis();
        System.out.println("天数：" + (time1 - time2) / (24 * 60 * 60 * 1000));

        Scanner scan = new Scanner(System.in);
        System.out.println("请输入你的生日，格式如：xxxx-xx-xx");
        Calendar canlendar = Calendar.getInstance();
        String str = scanner.nextLine();
        String year = str.substring(0, 4);
        String month = str.substring(6, 7);
        String day = str.substring(9,10);
        time.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
        System.out.println("你的生日是星期几:");

        int week = time.get(Calendar.DAY_OF_WEEK);
        switch (week) {
            case 1:
                System.out.println("星期天");
                break;
            case 2:
                System.out.println("星期一");
                break;
            case 3:
                System.out.println("星期二");
                break;
            case 4:
                System.out.println("星期三");
                break;
            case 5:
                System.out.println("星期四");
                break;
            case 6:
                System.out.println("星期五");
                break;
            default:
                System.out.println("星期六");
                break;
        }
    }
}